import request from '@/utils/request'
/**
 * 分页信息列表
 * @param pageNum
 * @param pageSize
 */
const getList = function(pageNum, pageSize, params) {
  return request({
    url: '/receipt/list',
    method: 'post',
    data: params != null ? params : {}
  })
}

/**
 * 更新订单
 * @param data
 */
const update = function(data) {
  return request({
    url: '/receipt/update',
    method: 'post',
    data: data
  })
}
/**
 * 条件分页检索列表
 * @param data
 */
const search = function(data) {
  return request({
    url: '/receipt/search?pageNum='+data.pageNum+"&pageSize="+data.pageSize+"&mobile="+data.mobile+"&date="+data.date,
    method: 'get'
  })
}

/**
 * 条件分页检索列表
 * @param data
 */
const getStock = function(data) {
  return request({
    url: '/sysStock/getCustomerInfo?mobile='+data.mobile,
    method: 'get'
  })
}

/**
 * 批量下载
 * @param url
 * @param data
 */
const batchDownload = function(url,type,ids) {
  window.location.href = url + '/receipt/batchDownload?type='+type+'&ids='+ids;
}
//获取可用套餐
const getAllSetMeal = function (data) {
  sessionStorage.setItem("agentCode",data.agentCode)
  return request({
    url: '/setMeal/getSetMeal2?miles='+data.miles+'&registerDate='+new Date(data.registerDate).getTime()+'&isUsedcar='+data.isUsedcar+'&mealType='+data.mealType+'&carModelId='+data.carModelId,
    method: 'get'
  })
}

export const orderApi = {
  getList: getList,
  update:update,
  search:search,
  getStock:getStock,
  getContract: getContract,
  orderExcelDownload: orderExcelDownload,
  batchDownload: batchDownload,
  getAllSetMeal:getAllSetMeal,

}
